<style type="text/css">
  .level_0 span{
     
    font-weight: bold;
    font-size: 20px;
  }
  .level_1 span{
    font-size:16px;
    
  }
  .level_2 span{
    font-size:12px;
     
  } 
  .gez{
    width:40px;
    height:20px;
    display: block;
    float:left;
  }
</style>
  <div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">角色</label>
      <div class="layui-input-block">
        <input  autocomplete="off" class="layui-input" lay-verify="required" type="text" name="r_name" id="" value="{$data.r_name}">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">权限范围</label>
      <div class="layui-input-block">
      <dl>
      {volist name="menus" id="v" }
          <dd class="level_{$v.level} "  >
          
          {$v.level|str_repeat="<span class='gez'></span>",###|raw}
          <input type="checkbox" lay-filter="access" name="r_auth[]" value="{$v.id}" lay-skin="primary" title="{$v.name}" rel="{$v.path_str}" 
          {in name="v.id" value="$data.r_auth"}checked{/in}  />
        </dd>      
        {/volist}
      </dl>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">具体描述</label>
      <div class="layui-input-block">
        <textarea type="text" name="r_desc"   autocomplete="off" class="layui-textarea">{$data.r_desc}</textarea>
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <button class="layui-btn" lay-submit lay-filter="LAY-user-role-submit" id="LAY-user-role-submit">提交</button>
    </div>
  </div>
  <script>
  layui.use(['index' ,'form'], function(){
    var $ = layui.$
    ,form = layui.form ;
    form.on("checkbox(access)",function(data){
      
        let rel = $(this).attr("rel");     
       $(this).closest('div').find("input[rel^='"+rel+"']").not(self).prop('checked',data.elem.checked);
       form.render();
       
    })
    
  })
  </script>
